package com.shipwe.loans.base.app

import android.app.Activity
import android.app.Application
import android.os.Bundle
import com.shipwe.loans.utils.log.ShipweLogger

/**
 * ActivityLifecycleCallbacksImpl
 * @Author wwdeng
 * @CreateTime: 2024/10/15 10:55
 * @Annotation： Activity生命周期监听
 */
class ActivityLifecycleCallbacksImpl: Application.ActivityLifecycleCallbacks {

    override fun onActivityCreated(activity: Activity, bundle: Bundle?) {
        ShipweStackManager.addActivityToStack(activity)
        ShipweLogger.e("${activity.javaClass.simpleName} --> onActivityCreated")
    }

    override fun onActivityStarted(activity: Activity) {
        ShipweLogger.e("${activity.javaClass.simpleName} --> onActivityStarted")
        ForegroundBackgroundHelper.onActivityStarted()
    }

    override fun onActivityResumed(activity: Activity) {
        ShipweLogger.e("${activity.javaClass.simpleName} --> onActivityResumed")
    }

    override fun onActivityPaused(activity: Activity) {
        ShipweLogger.e("${activity.javaClass.simpleName} --> onActivityPaused")
    }

    override fun onActivityStopped(activity: Activity) {
        ShipweLogger.e("${activity.javaClass.simpleName} --> onActivityStopped")
        ForegroundBackgroundHelper.onActivityStopped()
    }

    override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
        ShipweLogger.e("${activity.javaClass.simpleName} --> onActivitySaveInstanceState")
    }

    override fun onActivityDestroyed(activity: Activity) {
        ShipweStackManager.popActivityToStack(activity)
        ShipweLogger.e("${activity.javaClass.simpleName} --> onActivityDestroyed")
    }
}